package kr.hkit.powerjava.chapter18;

import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JButton;

import java.awt.Dialog;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.BoxLayout;
import javax.swing.SwingConstants;
import java.awt.Component;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.FlowLayout;

public class Panel_Dialog2 extends JPanel implements ActionListener {
	private JButton btn02;
	private JButton btn01;
	Panel_JDialog3 aDialog;

	/**
	 * Create the panel.
	 */
	public Panel_Dialog2() {
		
		btn01 = new JButton("대화상자 생성");
		btn01.setBounds(70, 82, 138, 23);
		btn01.setAlignmentX(Component.RIGHT_ALIGNMENT);
		btn01.addActionListener(this);
		setLayout(null);
		add(btn01);
		
		btn02 = new JButton("종료");
		btn02.setBounds(218, 82, 89, 23);
		btn02.addActionListener(this);
		add(btn02);

	}

	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == btn01) {
			actionPerformedBtn01(e);
		}
		if (e.getSource() == btn02) {
			actionPerformedBtn02(e);
		}
	}
	
	protected void actionPerformedBtn01(ActionEvent e) { //대화상자 팝업창 생성
		if(aDialog == null){
			aDialog = new Panel_JDialog3();
			}
			aDialog.setVisible(true);
//			btn01.requestFocus();
	}
	
	protected void actionPerformedBtn02(ActionEvent e) {
		System.exit(0);
	}
}
